/*package com.example.test;

import android.content.Context;
import android.content.res.Resources;
import android.widget.Toast;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.Socket;
import java.net.UnknownHostException;

import com.example.util.L;

public class SocketClient
{
  static int CONNECTION_WAIT_MILIS = 0;
  static int CONNECTION_WAIT_MILIS_SCENE = 0;
  public static SocketClient Current;
  private static boolean isUDP = false;
  public static final int maxNum = 2;
  private Socket clientSocket;
  public int curNum = 0;
  private DataInputStream dataInput;
  private DataOutputStream fileOut;
  private String hostId = "";
  private BufferedReader in;
  private String ip;
  public boolean isP2pServer = false;
  private boolean isReadOk = false;
  private PrintWriter out;
  private String response = "";
  private int socket;
  private boolean socketCreated = false;

  public SocketClient(String paramString, int paramInt)
  {
    this.ip = paramString;
    this.socket = paramInt;
    this.socketCreated = false;
  }

  public static boolean isUDP(String paramString)
  {
    isUDP = false;
    new byte[2048];
    byte[] arrayOfByte1 = (paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + paramString + "").getBytes();
    JKClient.Init("115.29.232.63", '鈱�');
    byte[] arrayOfByte2;
    if (JKClient.Query(paramString, arrayOfByte1) > 0)
    {
      L.Debug("鏌ヨ璁惧姝ｅ父", "");
      isUDP = true;
      arrayOfByte2 = new byte[100];
      String str1 = "HOST-CHKLIC-" + paramString + "";
      if (JKClient.Send(paramString, str1.getBytes(), (char)str1.length()) <= 0)
        break label441;
      L.Debug("鍙戦�侀獙璇佹寚浠ゆ垚鍔�", "");
    }
    String str2;
    while (true)
    {
      int i = JKClient.Recv(arrayOfByte2, 1500, 1000);
      str2 = new String(arrayOfByte2);
      if (i <= 0)
        break;
      L.Debug("鍥炲楠岃瘉鎸囦护鎴愬姛", "");
      L.Debug("p2p鍥炲鎸囦护锛�", str2.trim());
      isUDP = true;
      JKClient.Exit();
      return isUDP;
      L.Debug("鏌ヨ璁惧寮傚父", "");
      isUDP = false;
      JKClient.Exit();
      return isUDP;
      label441: L.Debug("鍙戦�侀獙璇佸紓甯� ", "");
    }
    L.Debug("鍥炲楠岃瘉寮傚父 ", "");
    L.Debug("p2p鍥炲寮傚父鎸囦护锛�", str2.trim());
    isUDP = false;
    JKClient.Exit();
    return isUDP;
  }

  public void closeConnection()
  {
    if (!this.isP2pServer);
    try
    {
      this.socketCreated = false;
      if (this.out != null)
        this.out.close();
      if (this.in != null)
        this.in.close();
      if ((this.clientSocket != null) && (!this.clientSocket.isClosed()))
      {
        this.clientSocket.close();
        this.clientSocket = null;
      }
      return;
    }
    catch (UnknownHostException localUnknownHostException)
    {
      localUnknownHostException.printStackTrace();
      return;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
  }

  public void closeFileConnection()
  {
    if (!this.isP2pServer);
    try
    {
      if (this.out != null)
        this.out.close();
      if (this.dataInput != null)
        this.dataInput.close();
      if ((this.clientSocket != null) && (!this.clientSocket.isClosed()))
        this.clientSocket.close();
      return;
    }
    catch (UnknownHostException localUnknownHostException)
    {
      localUnknownHostException.printStackTrace();
      return;
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
  }

  public boolean createConnectionForFile(Context paramContext)
  {
    try
    {
      if (this.isP2pServer)
        return true;
      if (isConnect(paramContext))
        this.dataInput = new DataInputStream(new BufferedInputStream(this.clientSocket.getInputStream()));
      return this.socketCreated;
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
  }

  public String exchangeMessage(Context paramContext, String paramString)
  {
    Object localObject = "";
    if (isConnect(paramContext))
      L.Debug("鍙戦�佹寚浠わ細", paramString.trim());
    while (true)
    {
      try
      {
        this.out.write(paramString);
        this.out.flush();
        char[] arrayOfChar = new char[1024];
        if (this.in.read(arrayOfChar) >= -1)
        {
          String str = new String(arrayOfChar);
          localObject = str;
        }
        L.Debug("鍥炲鎸囦护锛�", ((String)localObject).trim());
        return ((String)localObject).trim();
      }
      catch (IOException localIOException)
      {
        localIOException.printStackTrace();
        continue;
      }
      L.Debug("鏈缓绔媠ocket閾炬帴锛屾垨socket閾炬帴寮傚父", "");
    }
  }

  public String exchangeMessage(String paramString)
  {
    this.curNum = 0;
    if (this.isP2pServer);
    for (this.response = p2pExchange(paramString); ; this.response = socketExchange(paramString))
      return this.response.trim();
  }

  public boolean exchangeMessage(String paramString1, String paramString2)
  {
    String str1;
    if ("RA".equals(paramString1))
      str1 = "PT2262_315M-SEND-";
    while (true)
    {
      String str2 = exchangeMessage(str1 + paramString2);
      return (str1 + "OK").equals(str2.trim());
      if ("RB".equals(paramString1))
        str1 = "PT2262_433M-SEND-";
      else if ("RC".equals(paramString1))
        str1 = "EV1527_315M-SEND-";
      else if ("RD".equals(paramString1))
        str1 = "EV1527_433M-SEND-";
      else
        str1 = "RFSTUY_315M-SEND-";
    }
  }

  public boolean exchangeMessage(String paramString, boolean paramBoolean, Context paramContext)
  {
    if (paramBoolean);
    for (String str = "RELAY-SET_RELAY-" + paramString + ",SINGLE_ON"; "RELAY-SET_RELAY-OK".equals(exchangeMessage(str).trim()); str = "RELAY-SET_RELAY-" + paramString + ",SINGLE_OFF")
    {
      Toast localToast2 = Toast.makeText(paramContext, paramContext.getResources().getString(2131296337), 0);
      localToast2.setGravity(81, 0, 0);
      localToast2.show();
      return true;
    }
    Toast localToast1 = Toast.makeText(paramContext, paramContext.getResources().getString(2131296335), 0);
    localToast1.setGravity(81, 0, 0);
    localToast1.show();
    return false;
  }

  public String exchangeMessageScene(String paramString)
  {
    this.curNum = 0;
    if (this.isP2pServer);
    for (this.response = p2pExchangeScene(paramString); ; this.response = socketExchange(paramString))
      return this.response.trim();
  }

  public String exchangeMessageZip(String paramString)
  {
    this.curNum = 0;
    if (this.isP2pServer);
    for (this.response = p2pExchange(paramString); ; this.response = socketExchangeZip(paramString))
      return this.response.trim();
  }

  // ERROR //
  @android.annotation.SuppressLint({"DefaultLocale"})
  public String getBufferInLoop(int paramInt)
  {
    // Byte code:
    //   0: iconst_1
    //   1: anewarray 4	java/lang/Object
    //   4: astore_2
    //   5: aload_2
    //   6: iconst_0
    //   7: iload_1
    //   8: invokestatic 318	java/lang/Integer:valueOf	(I)Ljava/lang/Integer;
    //   11: aastore
    //   12: ldc_w 320
    //   15: aload_2
    //   16: invokestatic 324	java/lang/String:format	(Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/String;
    //   19: astore_3
    //   20: ldc 50
    //   22: astore 4
    //   24: iload_1
    //   25: bipush 23
    //   27: if_icmpne +13 -> 40
    //   30: ldc_w 326
    //   33: ldc_w 326
    //   36: invokestatic 332	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   39: pop
    //   40: aload_0
    //   41: getfield 82	com/test/SocketClient:out	Ljava/io/PrintWriter;
    //   44: new 87	java/lang/StringBuilder
    //   47: dup
    //   48: invokespecial 88	java/lang/StringBuilder:<init>	()V
    //   51: ldc_w 334
    //   54: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   57: aload_3
    //   58: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   61: invokevirtual 98	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   64: invokevirtual 214	java/io/PrintWriter:write	(Ljava/lang/String;)V
    //   67: aload_0
    //   68: getfield 82	com/test/SocketClient:out	Ljava/io/PrintWriter;
    //   71: invokevirtual 217	java/io/PrintWriter:flush	()V
    //   74: ldc2_w 335
    //   77: invokestatic 342	java/lang/Thread:sleep	(J)V
    //   80: sipush 1024
    //   83: newarray char
    //   85: astore 6
    //   87: aload_0
    //   88: getfield 78	com/test/SocketClient:in	Ljava/io/BufferedReader;
    //   91: aload 6
    //   93: invokevirtual 221	java/io/BufferedReader:read	([C)I
    //   96: pop
    //   97: new 100	java/lang/String
    //   100: dup
    //   101: aload 6
    //   103: invokespecial 224	java/lang/String:<init>	([C)V
    //   106: astore 8
    //   108: sipush 1024
    //   111: newarray char
    //   113: pop
    //   114: aload 8
    //   116: new 87	java/lang/StringBuilder
    //   119: dup
    //   120: invokespecial 88	java/lang/StringBuilder:<init>	()V
    //   123: ldc_w 344
    //   126: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   129: aload_3
    //   130: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   133: invokevirtual 98	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   136: invokevirtual 348	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   139: iflt +86 -> 225
    //   142: aload 8
    //   144: new 87	java/lang/StringBuilder
    //   147: dup
    //   148: invokespecial 88	java/lang/StringBuilder:<init>	()V
    //   151: ldc_w 344
    //   154: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   157: aload_3
    //   158: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   161: ldc_w 350
    //   164: invokevirtual 92	java/lang/StringBuilder:append	(Ljava/lang/String;)Ljava/lang/StringBuilder;
    //   167: invokevirtual 98	java/lang/StringBuilder:toString	()Ljava/lang/String;
    //   170: ldc 50
    //   172: invokevirtual 354	java/lang/String:replace	(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
    //   175: invokevirtual 150	java/lang/String:trim	()Ljava/lang/String;
    //   178: astore 10
    //   180: aload 10
    //   182: astore 4
    //   184: iload_1
    //   185: iconst_1
    //   186: if_icmpne +43 -> 229
    //   189: aload 4
    //   191: iconst_1
    //   192: invokevirtual 357	java/lang/String:substring	(I)Ljava/lang/String;
    //   195: areturn
    //   196: astore 7
    //   198: aload 7
    //   200: invokevirtual 185	java/io/IOException:printStackTrace	()V
    //   203: goto -106 -> 97
    //   206: astore 5
    //   208: aload 5
    //   210: invokevirtual 358	java/lang/Exception:printStackTrace	()V
    //   213: aload 4
    //   215: areturn
    //   216: astore 5
    //   218: aload 8
    //   220: astore 4
    //   222: goto -14 -> 208
    //   225: aload 8
    //   227: astore 4
    //   229: aload 4
    //   231: areturn
    //
    // Exception table:
    //   from	to	target	type
    //   87	97	196	java/io/IOException
    //   40	87	206	java/lang/Exception
    //   87	97	206	java/lang/Exception
    //   97	108	206	java/lang/Exception
    //   189	196	206	java/lang/Exception
    //   198	203	206	java/lang/Exception
    //   108	180	216	java/lang/Exception
  }

  // ERROR //
  public String getFile(String paramString)
  {
    // Byte code:
    //   0: aload_0
    //   1: aload_1
    //   2: invokevirtual 246	com/test/SocketClient:exchangeMessage	(Ljava/lang/String;)Ljava/lang/String;
    //   5: ldc_w 334
    //   8: ldc 50
    //   10: invokevirtual 354	java/lang/String:replace	(Ljava/lang/CharSequence;Ljava/lang/CharSequence;)Ljava/lang/String;
    //   13: invokevirtual 150	java/lang/String:trim	()Ljava/lang/String;
    //   16: astore_2
    //   17: aload_2
    //   18: ldc_w 350
    //   21: invokevirtual 363	java/lang/String:split	(Ljava/lang/String;)[Ljava/lang/String;
    //   24: iconst_0
    //   25: aaload
    //   26: invokestatic 366	java/lang/Integer:parseInt	(Ljava/lang/String;)I
    //   29: istore 4
    //   31: new 368	java/lang/StringBuffer
    //   34: dup
    //   35: invokespecial 369	java/lang/StringBuffer:<init>	()V
    //   38: astore 5
    //   40: iload 4
    //   42: ifle +111 -> 153
    //   45: aload_0
    //   46: getfield 82	com/test/SocketClient:out	Ljava/io/PrintWriter;
    //   49: ldc_w 371
    //   52: invokevirtual 214	java/io/PrintWriter:write	(Ljava/lang/String;)V
    //   55: aload_0
    //   56: getfield 82	com/test/SocketClient:out	Ljava/io/PrintWriter;
    //   59: invokevirtual 217	java/io/PrintWriter:flush	()V
    //   62: sipush 1024
    //   65: newarray char
    //   67: astore 7
    //   69: aload_0
    //   70: getfield 78	com/test/SocketClient:in	Ljava/io/BufferedReader;
    //   73: lconst_1
    //   74: invokevirtual 375	java/io/BufferedReader:skip	(J)J
    //   77: pop2
    //   78: aload_0
    //   79: getfield 78	com/test/SocketClient:in	Ljava/io/BufferedReader;
    //   82: aload 7
    //   84: invokevirtual 221	java/io/BufferedReader:read	([C)I
    //   87: iconst_m1
    //   88: if_icmplt +65 -> 153
    //   91: new 100	java/lang/String
    //   94: dup
    //   95: aload 7
    //   97: invokespecial 224	java/lang/String:<init>	([C)V
    //   100: astore 10
    //   102: sipush 1024
    //   105: newarray char
    //   107: astore 7
    //   109: ldc_w 377
    //   112: aload 10
    //   114: invokestatic 332	android/util/Log:e	(Ljava/lang/String;Ljava/lang/String;)I
    //   117: pop
    //   118: aload 10
    //   120: ldc_w 379
    //   123: invokevirtual 348	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   126: iconst_m1
    //   127: if_icmple +35 -> 162
    //   130: aload 5
    //   132: aload 10
    //   134: iconst_0
    //   135: aload 10
    //   137: ldc_w 379
    //   140: invokevirtual 348	java/lang/String:indexOf	(Ljava/lang/String;)I
    //   143: invokevirtual 382	java/lang/String:substring	(II)Ljava/lang/String;
    //   146: invokevirtual 150	java/lang/String:trim	()Ljava/lang/String;
    //   149: invokevirtual 385	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   152: pop
    //   153: aload 5
    //   155: invokevirtual 386	java/lang/StringBuffer:toString	()Ljava/lang/String;
    //   158: areturn
    //   159: astore_3
    //   160: aload_2
    //   161: areturn
    //   162: aload 5
    //   164: aload 10
    //   166: invokevirtual 150	java/lang/String:trim	()Ljava/lang/String;
    //   169: invokevirtual 385	java/lang/StringBuffer:append	(Ljava/lang/String;)Ljava/lang/StringBuffer;
    //   172: pop
    //   173: goto -95 -> 78
    //   176: astore 6
    //   178: aload 6
    //   180: invokevirtual 185	java/io/IOException:printStackTrace	()V
    //   183: goto -30 -> 153
    //
    // Exception table:
    //   from	to	target	type
    //   17	31	159	java/lang/Exception
    //   45	78	176	java/io/IOException
    //   78	153	176	java/io/IOException
    //   162	173	176	java/io/IOException
  }

  public String getHostId()
  {
    return this.hostId;
  }

  public String getNewFile(String paramString)
  {
    String str1 = exchangeMessage(paramString).replace("FILE-READ-", "").trim();
    try
    {
      int k = Integer.parseInt(str1.split(",")[1]);
      i = k;
      StringBuffer localStringBuffer = new StringBuffer();
      if (i > 0)
      {
        j = 1;
        if (j <= i)
        {
          Object[] arrayOfObject = new Object[1];
          arrayOfObject[0] = Integer.valueOf(j);
          String str2 = String.format("%03d", arrayOfObject);
          try
          {
            this.out.write("FILE-READ-" + str2);
            this.out.flush();
            char[] arrayOfChar = new char[1024];
            try
            {
              this.in.read(arrayOfChar);
              String str3 = new String(arrayOfChar);
              new char[1024];
              if (str3.indexOf("SUCCEED-READ-" + str2) < 0)
                break label279;
              String str4 = str3.replace("SUCCEED-READ-" + str2 + ",", "").trim();
              if (j == 1)
                str4 = str4.substring(1);
              localStringBuffer.append(str4);
            }
            catch (IOException localIOException)
            {
              while (true)
                localIOException.printStackTrace();
            }
          }
          catch (Exception localException2)
          {
            localException2.printStackTrace();
          }
        }
      }
      return localStringBuffer.toString();
    }
    catch (Exception localException1)
    {
      while (true)
      {
        int j;
        int i = 0;
        continue;
        label279: j++;
      }
    }
  }

  public void getP2pRev()
  {
    try
    {
      byte[] arrayOfByte = new byte[1024];
      int i = JKClient.Recv(arrayOfByte, arrayOfByte.length, 1000);
      if (i > 0)
      {
        L.Debug("FILE-READ-START 鍥炲鎸囦护鎴愬姛", "retRecv=" + i);
        if (i > -1)
        {
          String str = new String(arrayOfByte);
          if (str.indexOf("FILE-READ-END") > -1)
          {
            this.fileOut.write(arrayOfByte, 0, i - 14);
            this.fileOut.flush();
            this.isReadOk = true;
          }
          while (true)
          {
            L.Debug("tmp", str);
            L.Debug("else1 run", "");
            return;
            this.fileOut.write(arrayOfByte, 0, i);
            getP2pRev();
          }
        }
      }
    }
    catch (IOException localIOException)
    {
      localIOException.printStackTrace();
    }
  }

  public boolean getP2pZip(String paramString)
  {
    this.curNum = 0;
    int i = getZipSize(paramString);
    this.isReadOk = false;
    if (i > 0)
    {
      JKClient.Init("115.29.232.63", '鈱�');
      if (JKClient.Send(this.hostId, "".getBytes(), (char)"".length()) <= 0)
        break label171;
      L.Debug("FILE-READ-START 鍙戦�佹寚浠ゆ垚鍔�", "");
    }
    try
    {
      while (true)
      {
        File localFile = new File(Config.CACHE_PATH + "tmpzip.zip");
        if (localFile.exists())
          localFile.deleteOnExit();
        localFile.createNewFile();
        this.fileOut = new DataOutputStream(new BufferedOutputStream(new BufferedOutputStream(new FileOutputStream(Config.CACHE_PATH + "tmpzip.zip"))));
        getP2pRev();
        JKClient.Exit();
        return this.isReadOk;
        label171: L.Debug("FILE-READ-START鍙戦�佹寚浠ゅ紓甯�", "");
      }
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
  }

  public boolean getSocketZip(String paramString)
  {
    int i = getZipSize(paramString);
    boolean bool = false;
    if (i > 0);
    try
    {
      this.out.write("FILE-READ-START");
      this.out.flush();
      File localFile = new File(Config.CACHE_PATH + "tmpzip.zip");
      if (localFile.exists())
        localFile.deleteOnExit();
      localFile.createNewFile();
      byte[] arrayOfByte = new byte[40960];
      DataOutputStream localDataOutputStream = new DataOutputStream(new BufferedOutputStream(new BufferedOutputStream(new FileOutputStream(Config.CACHE_PATH + "tmpzip.zip"))));
      while (true)
      {
        int j = this.dataInput.read(arrayOfByte);
        if (j > -1)
        {
          if (new String(arrayOfByte).indexOf("FILE-READ-END") > -1)
          {
            localDataOutputStream.write(arrayOfByte, 0, j - 13);
            localDataOutputStream.flush();
            bool = true;
            return bool;
          }
          L.Debug("else1 run", "");
          localDataOutputStream.write(arrayOfByte, 0, j);
          arrayOfByte = new byte[1024];
        }
        else
        {
          L.Debug("else2 run", "");
          if (this.curNum >= 2)
            break;
          this.curNum = (1 + this.curNum);
          getSocketZip(paramString);
        }
      }
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        closeFileConnection();
        bool = false;
      }
      return false;
    }
    finally
    {
      closeFileConnection();
    }
  }

  public boolean getZipFile(String paramString)
  {
    if (this.isP2pServer)
      return getP2pZip(paramString);
    this.curNum = 0;
    return getSocketZip(paramString);
  }

  public int getZipSize(String paramString)
  {
    String str1 = exchangeMessageZip(paramString).trim();
    if ((str1.equals("FILE-READ-EMPTY")) || (str1.equals("FILE-READ-ERROR")))
      return 0;
    L.Debug("zip response", str1);
    String str2 = str1.replace("FILE-READ-", "").trim();
    int i = str2.indexOf(",");
    try
    {
      String str3 = str2.substring(0, i);
      L.Debug("zip num", str3);
      return Integer.parseInt(str3);
    }
    catch (IndexOutOfBoundsException localIndexOutOfBoundsException)
    {
      localIndexOutOfBoundsException.getStackTrace();
    }
    return 0;
  }

  public boolean isConnect(Context paramContext)
  {
    if (this.isP2pServer)
      return true;
    if ((this.clientSocket == null) || (!this.socketCreated) || (this.clientSocket.isClosed()) || (!this.clientSocket.isConnected()))
      L.Debug("conThread state run", "锛侊紒锛�");
    while (true)
    {
      try
      {
        L.Debug("Socket state", "寮�濮嬮摼鎺ワ紒");
        this.clientSocket = new Socket(this.ip, this.socket);
        this.clientSocket.setSoTimeout(CONNECTION_WAIT_MILIS);
        this.in = new BufferedReader(new InputStreamReader(this.clientSocket.getInputStream(), "UTF8"));
        this.out = new PrintWriter(this.clientSocket.getOutputStream(), true);
        this.socketCreated = true;
        L.Debug("Socket state", "宸茶繛鎺ョ姸鎬侊紒");
        if (!this.socketCreated)
        {
          L.Debug("Socket state", "澶勪簬鏈繛鎺ユ帴鐘舵�侊紒锛侊紒");
          Toast.makeText(paramContext, paramContext.getResources().getString(2131296446), 0).show();
        }
        return this.socketCreated;
      }
      catch (Exception localException)
      {
        this.socketCreated = false;
        L.Debug("Socket state Exception", "*****");
        localException.printStackTrace();
        continue;
      }
      try
      {
        this.clientSocket.sendUrgentData(255);
        L.Debug("Socket state", "鐩墠澶勪簬杩炴帴鎺ョ姸鎬侊紒");
        this.socketCreated = true;
      }
      catch (IOException localIOException)
      {
        this.socketCreated = false;
        L.Debug("socketCreated IOException", "寮傚父");
        localIOException.printStackTrace();
      }
    }
  }

  public boolean isConnectionForScene(Context paramContext)
  {
    this.socketCreated = false;
    if (this.isP2pServer)
      return true;
    Thread local1;
    if ((this.clientSocket == null) || (!this.socketCreated) || (this.clientSocket.isClosed()) || (!this.clientSocket.isConnected()))
    {
      L.Debug("conThread state run", "锛侊紒锛�");
      local1 = new Thread()
      {
        public void run()
        {
          try
          {
            L.Debug("Socket state", "寮�濮嬮摼鎺ワ紒");
            SocketClient.access$002(SocketClient.this, new Socket(SocketClient.this.ip, SocketClient.this.socket));
            SocketClient.this.clientSocket.setSoTimeout(SocketClient.CONNECTION_WAIT_MILIS_SCENE);
            SocketClient.access$302(SocketClient.this, new BufferedReader(new InputStreamReader(SocketClient.this.clientSocket.getInputStream(), "UTF8")));
            SocketClient.access$402(SocketClient.this, new PrintWriter(SocketClient.this.clientSocket.getOutputStream(), true));
            SocketClient.access$502(SocketClient.this, true);
            L.Debug("Socket state", "宸茶繛鎺ョ姸鎬侊紒");
            return;
          }
          catch (UnknownHostException localUnknownHostException)
          {
            SocketClient.access$502(SocketClient.this, false);
            L.Debug("Socket state UnknownHostException", "*****");
            localUnknownHostException.printStackTrace();
            return;
          }
          catch (IOException localIOException)
          {
            SocketClient.access$502(SocketClient.this, false);
            L.Debug("Socket state IOException", "****");
            localIOException.printStackTrace();
          }
        }
      };
      local1.start();
    }
    while (true)
    {
      try
      {
        local1.join(CONNECTION_WAIT_MILIS_SCENE);
        if (!this.socketCreated)
        {
          L.Debug("Socket state", "澶勪簬鏈繛鎺ユ帴鐘舵�侊紒锛侊紒");
          Toast.makeText(paramContext, paramContext.getResources().getString(2131296335), 0).show();
        }
        return this.socketCreated;
      }
      catch (InterruptedException localInterruptedException)
      {
        localInterruptedException.printStackTrace();
        continue;
      }
      try
      {
        this.clientSocket.sendUrgentData(255);
        L.Debug("Socket state", "鐩墠澶勪簬杩炴帴鎺ョ姸鎬侊紒");
        this.socketCreated = true;
      }
      catch (IOException localIOException)
      {
        this.socketCreated = false;
        L.Debug("socketCreated IOException", "寮傚父");
        localIOException.printStackTrace();
      }
    }
  }

  public boolean isP2pServer()
  {
    return this.isP2pServer;
  }

  public String p2pExchange(String paramString)
  {
    String str1 = paramString + "";
    L.Debug("p2p鍙戦�佹寚浠わ細", str1.trim());
    String str2 = "";
    byte[] arrayOfByte = new byte[100];
    String str3 = this.hostId;
    JKClient.Init("115.29.232.63", '鈱�');
    int i = JKClient.Send(str3, str1.getBytes(), (char)str1.length());
    if (i > 0)
    {
      L.Debug("鍙戦�佹寚浠ゆ垚鍔�", "");
      int j = JKClient.Recv(arrayOfByte, arrayOfByte.length, CONNECTION_WAIT_MILIS);
      JKClient.Exit();
      if (j <= 0)
        break label218;
      str2 = new String(arrayOfByte);
      L.Debug("p2p鍥炲鎸囦护鎴愬姛锛�", str2.trim());
      String str4 = "";
      if (!str2.trim().equals(""))
        str4 = str2.substring(-1 + str2.trim().length());
      if ((str4.equals("R")) && (this.curNum < 2))
      {
        L.Debug("p2p鍥炲鎸囦护閿欒锛�", str2.trim());
        this.curNum = (1 + this.curNum);
        p2pExchange(str1);
      }
    }
    while (true)
    {
      return str2.trim();
      L.Debug("鍙戦�佹寚浠ゅ紓甯�", "");
      return String.valueOf(i);
      label218: L.Debug("p2p鍥炲鎸囦护寮傚父锛�", str2.trim());
      if ((str2.equals("")) && (this.curNum < 2))
      {
        this.curNum = (1 + this.curNum);
        p2pExchange(str1);
      }
    }
  }

  public String p2pExchangeScene(String paramString)
  {
    String str1 = paramString + "";
    L.Debug("p2p鍙戦�佹寚浠わ細", str1.trim());
    String str2 = "";
    byte[] arrayOfByte = new byte[100];
    String str3 = this.hostId;
    JKClient.Init("115.29.232.63", '鈱�');
    int i = JKClient.Send(str3, str1.getBytes(), (char)str1.length());
    if (i > 0)
    {
      L.Debug("鍙戦�佹寚浠ゆ垚鍔�", "");
      int j = JKClient.Recv(arrayOfByte, arrayOfByte.length, CONNECTION_WAIT_MILIS_SCENE);
      JKClient.Exit();
      if (j <= 0)
        break label198;
      str2 = new String(arrayOfByte);
      L.Debug("p2p鍥炲鎸囦护鎴愬姛锛�", str2.trim());
      if ((str2.substring(-1 + str2.trim().length()).equals("R")) && (this.curNum < 2))
      {
        L.Debug("p2p鍥炲鎸囦护閿欒锛�", str2.trim());
        this.curNum = (1 + this.curNum);
        p2pExchange(str1);
      }
    }
    while (true)
    {
      return str2.trim();
      L.Debug("鍙戦�佹寚浠ゅ紓甯�", "");
      return String.valueOf(i);
      label198: L.Debug("p2p鍥炲鎸囦护寮傚父锛�", str2.trim());
      if ((str2.equals("")) && (this.curNum < 2))
      {
        this.curNum = (1 + this.curNum);
        p2pExchange(str1);
      }
    }
  }

  public void setHostId(String paramString)
  {
    this.hostId = paramString;
  }

  public void setP2pServer(boolean paramBoolean)
  {
    this.isP2pServer = paramBoolean;
  }

  public String socketExchange(String paramString)
  {
    L.Debug("socket鍙戦�佹寚浠わ細", paramString.trim());
    String str1 = "";
    try
    {
      this.out.write(paramString);
      this.out.flush();
      char[] arrayOfChar = new char[1024];
      if (this.in.read(arrayOfChar) >= -1)
        str1 = new String(arrayOfChar);
      L.Debug("socket鍥炲鎸囦护锛�", str1.trim());
      String str2 = "";
      if (!str1.trim().equals(""))
        str2 = str1.substring(-1 + str1.trim().length());
      if (((str1.trim().equals("")) || (str2.equals("R"))) && (this.curNum < 2))
      {
        this.curNum = (1 + this.curNum);
        socketExchange(paramString);
      }
      return str1.trim();
    }
    catch (IOException localIOException)
    {
      while (true)
      {
        localIOException.printStackTrace();
        closeConnection();
      }
    }
    finally
    {
      closeConnection();
    }
  }

  public String socketExchangeZip(String paramString)
  {
    L.Debug("socket鍙戦�佹寚浠わ細", paramString.trim());
    Object localObject = "";
    try
    {
      this.out.write(paramString);
      this.out.flush();
      char[] arrayOfChar = new char[1024];
      if (this.in.read(arrayOfChar) >= -1)
      {
        String str = new String(arrayOfChar);
        localObject = str;
      }
      L.Debug("socket鍥炲鎸囦护锛�", ((String)localObject).trim());
      if ((((String)localObject).trim().equals("")) && (this.curNum < 2))
      {
        this.curNum = (1 + this.curNum);
        socketExchange(paramString);
      }
      return ((String)localObject).trim();
    }
    catch (IOException localIOException)
    {
      while (true)
        localIOException.printStackTrace();
    }
  }
}

 Location:           D:\Program Files\Android\dex2jar-0.0.9.15\classes_dex2jar.jar
 * Qualified Name:     com.test.SocketClient
 * JD-Core Version:    0.6.2
 */